</para>
-<!-- ##### SECTION ./tmpl/from-drawables.sgml:See_Also ##### -->
- <para>
- gdk_image_get().
- </para>
-
-
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Short_Description ##### -->
Getting parts of a drawable's image data into a pixbuf.
GdkImage
gdk_image_new
GdkImageType
-gdk_image_new_bitmap
-gdk_image_get
-gdk_image_ref
-gdk_image_unref
-gdk_image_destroy
gdk_image_get_colormap
gdk_image_set_colormap
</para>
<para>
To create an empty #GdkImage use gdk_image_new().
-To create a #GdkImage from bitmap data use gdk_image_new_bitmap().
To create an image from part of a #GdkWindow use gdk_drawable_get_image().
</para>
<para>
To draw a #GdkImage in a #GdkWindow or #GdkPixmap use gdk_draw_image().
</para>
<para>
-To destroy a #GdkImage use gdk_image_destroy().
+To destroy a #GdkImage use g_object_unref().
</para>
<!-- ##### SECTION See_Also ##### -->
@GDK_IMAGE_FASTEST: Specifies that %GDK_IMAGE_SHARED should be tried first,
and if that fails then %GDK_IMAGE_NORMAL will be used.
-<!-- ##### FUNCTION gdk_image_new_bitmap ##### -->
-<para>
-</para>
-
-@visual:
-@data:
-@width:
-@height:
-@Returns:
-
-
-<!-- ##### FUNCTION gdk_image_get ##### -->
-<para>
-</para>
-
-@drawable:
-@x:
-@y:
-@width:
-@height:
-@Returns:
-
-
-<!-- ##### FUNCTION gdk_image_ref ##### -->
-<para>
-
-</para>
-
-@image:
-@Returns:
-
-
-<!-- ##### FUNCTION gdk_image_unref ##### -->
-<para>
-
-</para>
-
-@image:
-
-
-<!-- ##### MACRO gdk_image_destroy ##### -->
-<para>
-Destroys a #GdkImage, freeing any resources allocated for it.
-</para>
-
-<!-- # Unused Parameters # -->
-@image: a #GdkImage.
-
-
<!-- ##### FUNCTION gdk_image_get_colormap ##### -->
<para>
}
}
-GdkImage *
-gdk_image_new_bitmap (GdkVisual *visual,
- gpointer data,
- gint w,
- gint h)
-{
- GdkImage *image;
- GdkImageDirectFB *private;
-
- image = g_object_new (gdk_image_get_type (), NULL);
- private = image->windowing_data;
-
- image->type = GDK_IMAGE_SHARED;
- image->visual = visual;
- image->width = w;
- image->height = h;
- image->depth = 1;
-
- GDK_NOTE (MISC, g_print ("gdk_image_new_bitmap: %dx%d\n", w, h));
-
- g_message ("not fully implemented %s", G_STRFUNC);
-
- image->bpl = (w + 7) / 8;
- image->mem = g_malloc (image->bpl * h);
-#if G_BYTE_ORDER == G_BIG_ENDIAN
- image->byte_order = GDK_MSB_FIRST;
-#else
- image->byte_order = GDK_LSB_FIRST;
-#endif
- image->bpp = 1;
-
- return image;
-}
-
void
_gdk_windowing_image_init (void)
{
if (ret)
{
DirectFBError( "IDirectFBSurface::Lock() for writing failed!\n", ret );
- gdk_image_unref( image );
+ g_object_unref( image );
return NULL;
}
#if IN_HEADER(__GDK_IMAGE_H__)
#if IN_FILE(__GDK_IMAGE_C__)
-#ifndef GDK_DISABLE_DEPRECATED
-gdk_image_ref
-gdk_image_unref
-gdk_image_get
-#endif
gdk_image_set_colormap
gdk_image_get_colormap
gdk_image_new
#if IN_HEADER(__GDK_IMAGE_H__)
#if IN_FILE(__GDK_IMAGE_X11_C__)
-#ifdef GDK_ENABLE_BROKEN
-gdk_image_new_bitmap
-#endif
gdk_image_get_pixel
gdk_image_put_pixel
gdk_image_get_type G_GNUC_CONST
#include "gdkinternals.h" /* For scratch_image code */
#include "gdkalias.h"
-/**
- * gdk_image_ref:
- * @image: a #GdkImage
- *
- * Deprecated function; use g_object_ref() instead.
- *
- * Return value: the image
- *
- * Deprecated: 2.0: Use g_object_ref() instead.
- **/
-GdkImage *
-gdk_image_ref (GdkImage *image)
-{
- g_return_val_if_fail (GDK_IS_IMAGE (image), NULL);
-
- return g_object_ref (image);
-}
-
-/**
- * gdk_image_unref:
- * @image: a #GdkImage
- *
- * Deprecated function; use g_object_unref() instead.
- *
- * Deprecated: 2.0: Use g_object_unref() instead.
- **/
-void
-gdk_image_unref (GdkImage *image)
-{
- g_return_if_fail (GDK_IS_IMAGE (image));
-
- g_object_unref (image);
-}
-
-/**
- * gdk_image_get:
- * @drawable: a #GdkDrawable
- * @x: x coordinate in @window
- * @y: y coordinate in @window
- * @width: width of area in @window
- * @height: height of area in @window
- *
- * This is a deprecated wrapper for gdk_drawable_get_image();
- * gdk_drawable_get_image() should be used instead. Or even better: in
- * most cases gdk_pixbuf_get_from_drawable() is the most convenient
- * choice.
- *
- * Return value: a new #GdkImage or %NULL
- **/
-GdkImage*
-gdk_image_get (GdkWindow *drawable,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
- g_return_val_if_fail (x >= 0, NULL);
- g_return_val_if_fail (y >= 0, NULL);
- g_return_val_if_fail (width >= 0, NULL);
- g_return_val_if_fail (height >= 0, NULL);
-
- return gdk_drawable_get_image (drawable, x, y, width, height);
-}
-
/**
* gdk_image_set_colormap:
* @image: a #GdkImage
gint width,
gint height);
-#ifndef GDK_DISABLE_DEPRECATED
-GdkImage* gdk_image_get (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height);
-
-GdkImage * gdk_image_ref (GdkImage *image);
-void gdk_image_unref (GdkImage *image);
-#endif
-
void gdk_image_put_pixel (GdkImage *image,
gint x,
gint y,
GdkColormap* gdk_image_get_colormap (GdkImage *image);
-#ifdef GDK_ENABLE_BROKEN
-GdkImage* gdk_image_new_bitmap (GdkVisual *visual,
- gpointer data,
- gint width,
- gint height);
-#endif /* GDK_ENABLE_BROKEN */
-
-#ifndef GDK_DISABLE_DEPRECATED
-#define gdk_image_destroy g_object_unref
-#endif /* GDK_DISABLE_DEPRECATED */
-
G_END_DECLS
#endif /* __GDK_IMAGE_H__ */
return object_type;
}
-GdkImage *
-gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint width, gint height)
-{
- /* We don't implement this function because it's broken, deprecated and
- * tricky to implement. */
- g_warning ("This function is unimplemented");
-
- return NULL;
-}
-
GdkImage*
_gdk_image_new_for_depth (GdkScreen *screen,
GdkImageType type,
gdk_window_get_size (pixmap, &w, &h);
QTESTF (w == width, (" w:%d", w));
QTESTF (h == height, (" h:%d", h));
- image = gdk_image_get (pixmap, 0, 0, w, h);
+ image = gdk_drawable_get_image (pixmap, 0, 0, w, h);
QTEST (image != NULL);
QTEST (image->width == width);
QTEST (image->height == height);
QTEST (image->depth == depth);
- gdk_image_destroy (image);
+ g_object_unref (image);
g_object_unref (pixmap);
}
TEST (retval);
QTEST (image->depth == system_visual->depth);
QTEST (image->bpp >= (image->depth-1)/8 + 1);
QTEST (image->mem != NULL);
- gdk_image_destroy (image);
+ g_object_unref (image);
}
}
TEST (retval);
gdk_gc_get_values (gc, &gcvalues);
- image = gdk_image_get (drawable, x+-1, y+-1, 3, 3);
+ image = gdk_drawable_get_image (drawable, x+-1, y+-1, 3, 3);
QTEST (image != NULL);
for (xoff = -1; xoff <= 1; xoff++)
for (yoff = -1; yoff <= 1; yoff++)
{
oldpixels[xoff+1][yoff+1] = gdk_image_get_pixel (image, xoff+1, yoff+1);
}
- gdk_image_destroy (image);
+ g_object_unref (image);
if (depth == 32)
mask = 0xFFFFFFFF;
gdk_draw_point (drawable, gc, x, y);
- image = gdk_image_get (drawable, x-1, y-1, 3, 3);
+ image = gdk_drawable_get_image (drawable, x-1, y-1, 3, 3);
QTEST (image != NULL);
for (xoff = -1; xoff <= 1; xoff++)
for (yoff = -1; yoff <= 1; yoff++)
else
QTEST (newpixel == oldpixels[xoff+1][yoff+1]);
}
- gdk_image_destroy (image);
+ g_object_unref (image);
}
w_up = w_left = line_width/2;
w_down = w_right = (line_width & 1) ? line_width/2 : line_width/2-1;
gdk_window_get_size (drawable, &w, &h);
- oldimage = gdk_image_get (drawable, 0, 0, w, h);
+ oldimage = gdk_drawable_get_image (drawable, 0, 0, w, h);
if (depth == 32)
mask = 0xFFFFFFFF;
const gint y2 = y1;
gdk_draw_line (drawable, gc, x1, y1, x2, y2);
- newimage = gdk_image_get (drawable, 0, 0, w, h);
+ newimage = gdk_drawable_get_image (drawable, 0, 0, w, h);
for (x = x1-1; x <= x2+1; x++)
for (y = y1-w_up-1; y <= y1+w_down+1; y++)
{
const gint y2 = 13;
gdk_draw_line (drawable, gc, x1, y1, x2, y2);
- newimage = gdk_image_get (drawable, 0, 0, w, h);
+ newimage = gdk_drawable_get_image (drawable, 0, 0, w, h);
for (x = x1-w_left-1; x <= x1+w_right+1; x++)
for (y = y1-1; y <= y2+1; y++)
{
}
}
- gdk_image_destroy (oldimage);
- gdk_image_destroy (newimage);
+ g_object_unref (oldimage);
+ g_object_unref (newimage);
}
/* Test drawing lines.
}
gdk_window_get_size (drawable, &w, &h);
- oldimage = gdk_image_get (drawable, 0, 0, w, h);
+ oldimage = gdk_drawable_get_image (drawable, 0, 0, w, h);
if (depth == 32)
mask = 0xFFFFFFFF;
mask = (1 << depth) - 1;
gdk_draw_rectangle (drawable, gc, filled, x0, y0, width, height);
- newimage = gdk_image_get (drawable, 0, 0, w, h);
+ newimage = gdk_drawable_get_image (drawable, 0, 0, w, h);
for (x = x0 - 1; x <= x0 + width + 1; x++)
for (y = y0 - 1; y < y0 + height + 1; y++)
}
}
- gdk_image_destroy (oldimage);
- gdk_image_destroy (newimage);
+ g_object_unref (oldimage);
+ g_object_unref (newimage);
}
/* Test drawing rectangles.
}
gdk_window_get_size (drawable, &w, &h);
- oldimage = gdk_image_get (drawable, 0, 0, w, h);
+ oldimage = gdk_drawable_get_image (drawable, 0, 0, w, h);
if (depth == 32)
mask = 0xFFFFFFFF;
mask = (1 << depth) - 1;
/* XXX */
- newimage = gdk_image_get (drawable, 0, 0, w, h);
+ newimage = gdk_drawable_get_image (drawable, 0, 0, w, h);
for (x = x0 - 1; x <= x0 + width + 1; x++)
for (y = y0 - 1; y < y0 + height + 1; y++)
}
}
- gdk_image_destroy (oldimage);
- gdk_image_destroy (newimage);
+ g_object_unref (oldimage);
+ g_object_unref (newimage);
}
/* Test drawing arcs. Results don't have to be exactly as on X11,
return image;
}
-GdkImage *
-gdk_image_new_bitmap (GdkVisual *visual,
- gpointer data,
- gint w,
- gint h)
-{
- GdkPixmap *pixmap;
- GdkImage *image;
- guchar *bits;
- gint data_bpl = (w-1)/8 + 1;
- gint i;
-
- pixmap = gdk_pixmap_new (NULL, w, h, 1);
-
- if (pixmap == NULL)
- return NULL;
-
- GDK_NOTE (IMAGE, g_print ("gdk_image_new_bitmap: %dx%d=%p\n",
- w, h, GDK_PIXMAP_HBITMAP (pixmap)));
-
- bits = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->bits;
- image = _gdk_win32_new_image (visual, w, h, 1, bits);
- image->windowing_data = pixmap;
-
- if (data_bpl != image->bpl)
- {
- for (i = 0; i < h; i++)
- memmove ((guchar *) image->mem + i*image->bpl, ((guchar *) data) + i*data_bpl, data_bpl);
- }
- else
- memmove (image->mem, data, data_bpl*h);
-
- return image;
-}
-
void
_gdk_windowing_image_init (void)
{
}
}
-/**
- * gdk_image_new_bitmap:
- * @visual: the #GdkVisual to use for the image.
- * @data: the pixel data.
- * @width: the width of the image in pixels.
- * @height: the height of the image in pixels.
- *
- * Creates a new #GdkImage with a depth of 1 from the given data.
- * <warning><para>THIS FUNCTION IS INCREDIBLY BROKEN. The passed-in data must
- * be allocated by malloc() (NOT g_malloc()) and will be freed when the
- * image is freed.</para></warning>
- *
- * Return value: a new #GdkImage.
- **/
-GdkImage *
-gdk_image_new_bitmap (GdkVisual *visual,
- gpointer data,
- gint width,
- gint height)
-{
- Visual *xvisual;
- GdkImage *image;
- GdkDisplay *display;
- GdkImagePrivateX11 *private;
-
- image = g_object_new (gdk_image_get_type (), NULL);
- private = PRIVATE_DATA (image);
- private->screen = gdk_visual_get_screen (visual);
- display = GDK_SCREEN_DISPLAY (private->screen);
-
- image->type = GDK_IMAGE_NORMAL;
- image->visual = visual;
- image->width = width;
- image->height = height;
- image->depth = 1;
- image->bits_per_pixel = 1;
- if (display->closed)
- private->ximage = NULL;
- else
- {
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
- private->ximage = XCreateImage (GDK_SCREEN_XDISPLAY (private->screen),
- xvisual, 1, XYBitmap,
- 0, NULL, width, height, 8, 0);
- private->ximage->data = data;
- private->ximage->bitmap_bit_order = MSBFirst;
- private->ximage->byte_order = MSBFirst;
- }
-
- image->byte_order = MSBFirst;
- image->mem = private->ximage->data;
- image->bpl = private->ximage->bytes_per_line;
- image->bpp = 1;
- return image;
-}
-
void
_gdk_windowing_image_init (GdkDisplay *display)
{